package com.xsd.LambadaExpress;

/**
 * @Description: 拉姆达表达式练习
 * @Author: zhoufuzong
 * @Created: 2020-12-27 19:33:59
 * @Version: 1.1.0
 */


@FunctionalInterface  // 函数式接口，默认只有一个方法时，会自己加
interface Foo{
    // 有且只有一个方法 ，即函数式接口
//    public void sayHello();
    public int addInt(int x,int y);

    default int div(int x,int y){
        System.out.println("**** hello java****");
        return x/y;
    }

    public static int mv(int x, int y){
       return x*y;
    }

}


/**
 * 2.1 口诀：拷贝小括号，写死右箭头，落地大括号
 *
 * 2.2 @FunctionalInterface
 *
 * 2.3 default
 */
public class LambadaExpressDemo {


    public static void main(String[] args) {

//        Foo foo = new Foo() {
//            @Override
//            public void sayHello() {
//                System.out.println("hello java 2020");
//            }
//        };
//        Foo foo =()->{
//            System.out.println("**** hello java 20201227");
//        };
//        foo.sayHello();
        Foo foo = (x,y)->{
            System.out.println("com in here ");
            return x+y;
        };
        System.out.println(foo.addInt(3,5));

        System.out.println(foo.div(10,5));

        System.out.println(Foo.mv(3,5));
    }

}
